home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / HYPERCAR / XCMDS_&_ / SHOWMESS.0 / card_3051.txt < prev    next >
Text File  |  1990-03-31  |  8KB  |  186 lines

  1. -- card: 3051 from stack: in.0
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2670
  5. -- name: 
  6.  
  7.  
  8. -- part 4 (button)
  9. -- low flags: 00
  10. -- high flags: A004
  11. -- rect: left=318 top=306 right=328 bottom=418
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Show Script
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   edit the script of btn "Try It"
  23. end mouseUp
  24.  
  25.  
  26. -- part 5 (button)
  27. -- low flags: 00
  28. -- high flags: A004
  29. -- rect: left=94 top=306 right=328 bottom=194
  30. -- title width / last selected line: 0
  31. -- icon id / first selected line: 0 / 0
  32. -- text alignment: 1
  33. -- font id: 0
  34. -- text size: 12
  35. -- style flags: 0
  36. -- line height: 16
  37. -- part name: Try It
  38. ----- HyperTalk script -----
  39. ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó
  40. on showMessage string1,string2        --┬⌐1988 by Dean H. Wette
  41.   put return & string1 & return & string2 into fld Textframe
  42.   lock screen
  43.   show bg fld "Frame1"
  44.   show bg fld "Frame2"
  45.   show bg fld "TextFrame"
  46.   unlock screen
  47. end showMessage
  48.  
  49. on hideMessage                        --┬⌐1988 by Dean H. Wette
  50.   lock screen
  51.   hide bg fld "Frame1"
  52.   hide bg fld "Frame2"
  53.   hide bg fld "TextFrame"
  54.   unlock screen
  55.   put empty into bg fld "TextFrame"  --Don't leave the text hanging
  56. end hideMessage                      --around; that would be sloppy
  57. ┬á                                    --and, potentially, a great waste
  58. ┬á                                    --of space.
  59.  
  60. Really simple, huh?
  61. ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó
  62.  
  63. This is the script of the ΓÇÿTry ItΓÇÖ button. Take a look at the
  64. openStack handler also...
  65.  
  66. on mouseUp
  67.   hide cd fld about
  68.   showMessage "Doing something for a while.","Please wait..."
  69.   repeat 100
  70.     set cursor to busy
  71.   end repeat
  72.   set cursor to hand
  73.   hideMessage
  74. end mouseUp
  75. ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇö
  76.  
  77.  
  78. -- part 6 (field)
  79. -- low flags: 81
  80. -- high flags: 0002
  81. -- rect: left=28 top=54 right=293 bottom=488
  82. -- title width / last selected line: 0
  83. -- icon id / first selected line: 0 / 0
  84. -- text alignment: 0
  85. -- font id: 3
  86. -- text size: 10
  87. -- style flags: 0
  88. -- line height: 13
  89. -- part name: about
  90. ----- HyperTalk script -----
  91. on mouseUp
  92.   hide cd fld about
  93. end mouseUp
  94.  
  95.  
  96. -- part 8 (button)
  97. -- low flags: 00
  98. -- high flags: 2000
  99. -- rect: left=468 top=19 right=56 bottom=507
  100. -- title width / last selected line: 0
  101. -- icon id / first selected line: 14767 / 14767
  102. -- text alignment: 1
  103. -- font id: 0
  104. -- text size: 12
  105. -- style flags: 0
  106. -- line height: 16
  107. -- part name: New Button
  108. ----- HyperTalk script -----
  109. on mouseUp
  110.   if the visible of cd fld about is true then
  111.     hide cd fld about
  112.   else
  113.     showMessage "Who came up with this?","Click the mouse to find out..."
  114.     wait until the mouseClick
  115.     hideMessage
  116.     show cd fld about
  117.   end if
  118. end mouseUp
  119.  
  120.  
  121. -- part contents for card part 6
  122. ----- text -----
  123. ShowMessage is Copyright ┬⌐1988 by Dean H. Wette, All rights reserved.
  124.  
  125. There's no charge for ShowMessage, but if you use it, please credit me for its use in your stack.  
  126.  
  127. I'd also appreciate any comments you might have:
  128. ┬á┬á┬á┬áDean H. Wette
  129. ┬á┬á┬á┬á921 DeMun Ave. 2N
  130. ┬á┬á┬á┬áClayton, MO 63105
  131.  
  132. EMail to:
  133. ┬á┬á┬á┬áCI$ ΓÇö 72317,2034 [Dean Wette]
  134. ┬á┬á┬á┬áXBank BBS (415-426-8972) ΓÇö Dean Wette
  135. ┬á┬á┬á┬áMacNET ΓÇö address forthcoming
  136. ┬á┬á┬á┬áFIDONet ΓÇö Opus1: 100/255
  137.  
  138. Look for my other utility ΓÇ£ChangeObjectLayerΓÇ¥ and my record cataloger stack ΓÇ£ALBUMSΓÇ¥ on CI$, XBank, and MacNET.
  139.  
  140.  
  141. -- part contents for background part 4
  142. ----- text -----
  143. ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó┬áSHOWMESSAGE 1.0┬áΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó
  144. ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇö
  145. Who said utility documentation stacks had to be pretty?
  146. ΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇöΓÇö
  147. Currently, there are two standard methods of displaying a message to the user in HyperCard without using external code: the message box and the answer dialog. However, the message box is terribly ugly, especially when you have put a lot of work into an elegent graphic interface. The answer dialog isn't always appropriate because it requires a user response, and it disappears before a script can continue to execute.  Often what's needed is an elegent way of displaying a message, and the ability to control both invoking and hiding the message from within a script.  My solution is ShowMessage.
  148.  
  149. ShowMessage allows you to control both the display and disposal of a message window from within a script.  This is accomplished entirely using HyperCard objects and HyperTalk--no externals are required.  Once ShowMessage is set up in a stack, it's very easy to use. The syntax for ShowMessage is:
  150.  
  151. --display the message
  152. showMessage <string1> [<,string2>]
  153.  
  154. --hide the message
  155. hideMessage
  156.  
  157. So for example, if you want to display a message during the course of a lengthy script execution, you would do something like this:
  158.  
  159. on mouseUp
  160.   showMessage "Doing something for a while.","Please wait..."
  161.   --do something like...compact the stack...or sort all cards
  162.   --when the process is finished
  163.   hideMessage
  164. end mouseUp
  165.  
  166. Go ahead, try it out!
  167.  
  168. If  your script has a repeat loop, you can also 'set the cursor to busy' as a further indication that something is going on (and that the computer hasn't hung up).
  169.  
  170. Preparing ShowMessage for use is easy. First of all, put the showMessage and hideMessage handlers in your stack script.  Secondly, create the message window using three background fields: one for the outside part of the frame and two for the inside part. Name them (in order from back to front) Frame1, Frame2, and TextFrame. Of course, you can name them what you want, but be sure to change the handlers to reflect  any other names. 
  171.  
  172. Since you're a HC developer, I'll leave it to you to worry about adjusting the size of the window, and making sure the text looks right when it's displayed.  One word of warning though. If you have other buttons and fields in your stack, make sure the ShowMessage window appears on top of them (use 'Bring Forward' and 'Send Farther', or better yet, get my utility SetLayer a.k.a. ChangeObjectLayer).  If you're using card buttons and fields in your stack, you may need to construct the ShowMessage window from card fields (thus making it card specific).  If need be, you can have several sets of ShowMessage handlers and windows for cards and backgrounds, or for different size windows.  For Example:
  173.  
  174. showMessage1  string1,string2
  175. showMessage2  string1, string2
  176. etc...
  177.  
  178. Just make the necessary modifications to the handlers.  You're the developer! Use your imagination. But please remember, the concept and original handlers for ShowMessage came from me, so credit me if you use them. Thanks.
  179.  
  180. One final note: if the user aborts your script by typing Command-., you need to dispose of the window in an idle handler:
  181.  
  182. on idle
  183.   if the visible of fld "TextFrame" is true then hideMessage
  184. end idle
  185.  
  186. Of course, all this would be simpler in an XCMD., but no one has done it, and I'm not a programmer.